package com.heima.minio;


import io.minio.MinioClient;
import io.minio.PutObjectArgs;

import java.io.FileInputStream;

public class MinIOTest {

    public static void main(String[] args) throws Exception{

        //读取本地文件
        FileInputStream fileInputStream = new FileInputStream("D:\\list.html");

        //创建minio客户端
        MinioClient client = MinioClient.builder()
                .credentials("minio","minio123")//minio登录凭证
                .endpoint("http://192.168.200.130:9000") //minio链接地址
                .build();

        //上传
        PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                .object("list.html") //文件名称
                .bucket("leadnews") //桶名称
                .contentType("text/html") //文件类型
                .stream(fileInputStream,fileInputStream.available(),-1).build();
        client.putObject(putObjectArgs);

        //访问地址
        System.out.println("http://192.168.200.130:9000/leadnews/list.html");
    }
}